<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	<title>Dynatree - Example</title>

<!-- 	<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js' type='text/javascript'></script>  -->
	<script src='../jquery/jquery.js' type='text/javascript'></script>
	<script src='../jquery/ui.core.js' type='text/javascript'></script>
    <script src='../jquery/jquery.cookie.js' type='text/javascript'></script>

	<link href='../src/skin/ui.dynatree.css' rel='stylesheet' type='text/css'>
	<script src='../src/jquery.dynatree.js' type='text/javascript'></script>

	<!-- Start_Exclude: This block is not part of the sample code -->
	<link href="prettify.css" rel="stylesheet">
	<script src="prettify.js" type='text/javascript'></script>
	<link href='sample.css' rel='stylesheet' type='text/css'>
    <script src='sample.js' type='text/javascript'></script>
	<!-- End_Exclude -->
    
<script type='text/javascript'>
	$(function(){
		
		// --- Initialize sample trees
		$("#tree").dynatree({
			title: "Lazy loading sample",
			rootVisible: true,
			fx: { height: "toggle", duration: 200 },
            // In real life we would call a URL on the server like this:
//          initAjax: {
//              url: "/getTopLevelNodesAsJson",
//              data: { mode: "funnyMode" }
//              },
            // .. but here we use a local file instead:
			initAjax: { 
                url: "sample-data1.json" 
				},
			
			onActivate: function(dtnode) {
				$("#echoActive").text(dtnode.data.title);
			},

			onLazyRead: function(dtnode){
				// In real life we would call something like this:
//            	dtnode.appendAjax({
//            	    url: "/getChildrenAsJson",
//		            data: {key: dtnode.data.key,
//            		       mode: "funnyMode"
//                         }
//              });
                // .. but here we use a local file instead:
                dtnode.appendAjax({
                    url: "sample-data2.json" 
                });
			}
			
		});

	});
</script>
</head>

<body class="example">
	<h1>Example: Lazy loading</h1>
	<p class="description">
		Using 'lazy' option to load the tree and to load the branches.<br>
		<br>
		Note: the AJAX call is only simulated. Also, the <code>initAjax</code> option is not used.<br>
		You may want to try this <a href="sample-lazy-persist.html">live example</a> 
		of a lazy tree that uses a simple test server.
	</p>

	<div id="tree">
		<!-- When using initAjax, it may be nice to put a throbber here, that spins until the initial content is loaded: -->
	</div>

	<div>Active node: <span id="echoActive">-</span></div>

	<!-- Start_Exclude: This block is not part of the sample code -->
	<hr>
	<p class="sample-links  no_code">
		<a class="hideInsideFS" href="http://dynatree.googlecode.com">jquery.dynatree.js project home</a>
		<a class="hideOutsideFS" href="#">Link to this page</a>
		<a class="hideInsideFS" href="samples.html">Example Browser</a>
		<a href="#" class="codeExample">View source code</a>
	</p>
	<!-- End_Exclude -->
</body>
</html>
